from django.contrib import admin

# Register your models here.


from mysite.models import *

from django.db import models

# Create your models here.


from django.db import models

# Create your models here.
@admin.register(Book)
class BookAdmin(admin.ModelAdmin):
    list_display = ['title', 'price', 'publish_date',  'publish_id', 'author_name']


    def post_tag(self, obj):
        return

    def author_name(self, obj):
        return [au.name for au in obj.author.all()] #使用外键关联的字段来显示
    author_name.short_description = '作者'  # 设置显示名称


@admin.register(Publish)
class PublishAdmin(admin.ModelAdmin):
    list_display = ['name', 'addr', 'email']


@admin.register(Author)
class Author(admin.ModelAdmin):
    list_display = ['name', 'age', 'author_detail_id']
#

@admin.register(AuthorDetail)
class AuthorDetail(admin.ModelAdmin):
    list_display = ['phone', 'addr']
